﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DocumentRights_Edit.aspx.vb"
    Inherits="PubProject.DocumentRights_Edit" %>

<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mwc" Namespace="MySoft.WebControls" Assembly="MySoft.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title runat="server" id="mytitle">目录授权</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <link href="/_nav/menu.css" type="text/css" rel="stylesheet">
    <link href="/_common/styles/global.css" type="text/css" rel="stylesheet">
    <link href="/_grid/map_grid.css" type="text/css" rel="stylesheet">
    <link href="/_forms/styles/form.css" type="text/css" rel="stylesheet">
    <link href="/_nav/tabs.css" type="text/css" rel="stylesheet">
    <link href="/_nav/nav.css" type="text/css" rel="stylesheet">
    <link href="/_common/styles/select.css" type="text/css" rel="stylesheet">

    <script language="javascript" src="/_controls/settings.aspx"></script>

    <script language="javascript" src="/_controls/util/util.js"></script>

    <script language="javascript" src="/_controls/datetime/date.js"></script>

    <script language="javascript" src="/_controls/datetime/time.js"></script>

    <script language="javascript" src="/_controls/number/number.js"></script>

    <script language="javascript" src="/_controls/lookup/map_lookup.js"></script>

    <script language="javascript" src="/_nav/menu.js"></script>

    <script language="javascript" src="/_common/scripts/global.js"></script>

    <!-- Public -->

    <script language="javascript" src="/PubProject/JS/Public.js" type="text/javascript"></script>
    <script language="javascript" src="/XMJD/Js/Public.js" type="text/javascript"></script>
    		

    <script language="javascript">			
			//在线帮助文件
			 var _MyHelpfile = "/Xmjd/HELP/项目准备/业务参数设置.htm";
			
			// 界面初始化
			function window.onload()
			{
			 
			   if (document.getElementById("isTBcheck").checked==false )
			   {
			      document.getElementById("isTB").style.display ="none";
			   }
			
			}
			
			//用于控制  是否 将权限同步到子目录： 默认不勾选
			function onIsCheck()
			{
			    if (document.getElementById("isTBcheck").checked==false )
			   {
			      document.getElementById("isTB").style.display ="none";
			   }
			   else 
			   {
			      document.getElementById("isTB").style.display ="";
			   }			   
			}
			
			//保存
			function UserStationSave(sType)
			{
			 	var objTable = gridBar;
				var sStationUserGUID = '';
				var sStationUserName = '';
				var sStationUserType = '';				
				var strPath;
				
				for (var i = 1 ; i <= objTable.rows.length-1 ; i++)
				{
//				    下面的if  用于保存 选中的数据
//				    if(objTable.rows(i).childNodes[0].firstChild.checked)
//				    {
					    sStationUserGUID += ((sStationUserGUID=='')?'':',') + objTable.rows[i].StationUserGuid;
					    sStationUserName += ((sStationUserName=='')?'':',') + objTable.rows[i].cells[2].innerText;	
					    sStationUserType += ((sStationUserType=='')?'':',') + objTable.rows[i].cells[1].innerText;				
//					}
			    }				
				//var strReturn=sStationUserGUID + "|" + sStationUserName;
				var strReturn=sStationUserGUID + "|" + sStationUserType;				
			
			
			   // 得到保存方式 
			   var SaveType="0";
			  if (document.getElementById("isTBcheck").checked==true)
			   {
			      //初始化为1  ,1为覆盖，2为追加
			      SaveType="1";
			      if(document.getElementById("rdoAdd").checked==true)
			      {
			        SaveType="2";
			      }			     	    
			      //用通道进行保存		
			   }
			 
			    strPath="/PubProject/Pub_XMLHTTP.aspx?UserGuidAndType="+strReturn+"&DataGUID="+document.getElementById("DocumentGUID").value+"&SaveType="+SaveType;
			  
                var strHttpReturn=openXMLHTTP(strPath,"UserStationSave");
                
                if(sType && sType=="save")
                {
                    __doPostBack("","");
                }                                      
	  }
			
			//保存并关闭
			function SaveAndClose()
			{
			   UserStationSave("saveandclose");
			   window.close();
			}
			
			
			
			// 进行方案处理：Delete － 删除方案、Import － 引入方案、Compare － 方案对比
			function Ok()
			{
				var objTable = gridBar;
				var sStationUserGUID = '';
				var sStationUserName = '';
				for (var i = 1 ; i <= objTable.rows.length-1 ; i++)
				{
					sStationUserGUID += ((sStationUserGUID=='')?'':',') + objTable.rows[i].StationUserGuid;
					sStationUserName += ((sStationUserName=='')?'':',') + objTable.rows[i].cells[2].innerText;					
				}				
				parent.window.returnValue=sStationUserGUID + "|" + sStationUserName;
				parent.window.close();
			}
			
			function UserAdd()
			{   
				var sRtn = SelectUserBolc("选择授权用户","1","1",document.all("txtJTGUID").value);
				
				if ( sRtn == undefined ) return;
				var objTable = gridBar;
				var sUserGUID,sUserName,sUserCode,sDeptName;
				for ( var i = 0; i < sRtn.items.length; i++)
				{
				    
					sUserGUID = sRtn.items[i].id;
					sUserName = sRtn.items[i].name;
					sUserCode = sRtn.items[i].values[0].value;
					sDeptName = sRtn.items[i].values[2].value;
					
					if(sUserCode == "")
					{
					    break;
					}
					//是否存在已选择的用户
					var sign = false ;
					for (var j=1 ; j < objTable.rows.length; j++)
					{
						if (objTable.rows[j].StationUserGuid == sUserGUID)
						{
							sign = true;
							break;
						}
					}
					if (!sign)
					{
						var objAddRow = gridBar.insertRow(gridBar.rows.length);
						objAddRow.setAttribute("StationUserGuid", sUserGUID);						
						objAddRow.style.height = "24px";
						var objAddCell;
						
						objAddCell = objAddRow.insertCell(0);
						objAddCell.align = "center";
						objAddCell.className = "gridBorder";						
						objAddCell.insertAdjacentHTML("BeforeEnd",'<input type="checkbox" id="chk_User">');						
						objAddCell.colSpan = "2";
						
						objAddCell = objAddRow.insertCell(1);
						objAddCell.align = "left";
						objAddCell.className = "gridBorder";
						objAddCell.insertAdjacentHTML("BeforeEnd","用户");						
						objAddCell.width = "80px";
						objAddCell.colSpan = "2";
						
					
						objAddCell = objAddRow.insertCell(2);
						objAddCell.align = "left";
						objAddCell.className = "gridBorder";
						objAddCell.insertAdjacentHTML("BeforeEnd",sUserName);
						objAddCell.colSpan = "2";
					}					
				}				
			}
			
			function UserStation()
			{				
				var sHeight = 600;
				var sWidth = 800;
								
				var url = "/Xmjd/PUB/SelectOrganizationStationForLookup.aspx";
				//var strReturn=openMyDlg( url, "", "dialogHeight:" + sHeight + "px; dialogWidth:" + sWidth + "px; help:no; status:no;scroll:no;") ;
				var strReturn=openMyDlg("选择岗位",url,"","","800","600");
				if ( strReturn == undefined ) return;
				var objTable = gridBar;
				var arrUserGUID,arrUserName;
				var sUserGUID,sUserName;
				var arrRtn;
				arrRtn=strReturn.split("|");
				
				arrUserGUID=arrRtn[0].split(",");
				arrUserName=arrRtn[1].split(",");
				
				for ( var i = 0; i < arrUserGUID.length; i++)
				{
					sUserGUID = arrUserGUID[i];
					sUserName = arrUserName[i];
					sUserCode = "";
					sDeptName = "";
					//是否存在已选择的用户
					var sign = false ;
					for (var j=1 ; j < objTable.rows.length; j++)
					{
						if (objTable.rows[j].StationUserGuid == sUserGUID)
						{
							sign = true;
							break;
						}
					}
					if (!sign)
					{
						var objAddRow = gridBar.insertRow(gridBar.rows.length);
						objAddRow.setAttribute("StationUserGuid", sUserGUID);						
						objAddRow.style.height = "24px";
						var objAddCell;
						
						objAddCell = objAddRow.insertCell(0);
						objAddCell.align = "center";
						objAddCell.className = "gridBorder";						
						objAddCell.insertAdjacentHTML("BeforeEnd",'<input type="checkbox" id="chk_User">');						
						objAddCell.colSpan = "2";
						
						objAddCell = objAddRow.insertCell(1);
						objAddCell.align = "left";
						objAddCell.className = "gridBorder";
						objAddCell.insertAdjacentHTML("BeforeEnd","岗位");						
						objAddCell.width = "80px";
						objAddCell.colSpan = "2";
						
					
						objAddCell = objAddRow.insertCell(2);
						objAddCell.align = "left";
						objAddCell.className = "gridBorder";
						objAddCell.insertAdjacentHTML("BeforeEnd",sUserName);
						objAddCell.colSpan = "2";
					}
				}
			}
			
			function Delete()
			{
				var objTable = gridBar;
				if (objTable.rows.length > 1)
				{
					for (var i = objTable.rows.length-1 ; i >= 1 ; i--)
					{
						var objCheck = objTable.rows[i].cells[0].children[0];
						if (objCheck.checked)
						{
							gridBar.deleteRow(i);
						}
					}
				}
				else
				{
					return;
				}
				
			}
			// 全选、取消全选
			function doCheckAll(obj)
			{
				var blchecked = obj.checked;
				var oTable = document.all("gridBar");
				
				for( var i = 1; i < oTable.rows.length; i++)
				{
					oTable.rows[i].cells[0].children[0].checked = blchecked;
				}
			}

		
    </script>

</head>
<body ms_positioning="GridLayout" >
    <form id="Form1" runat="server">
    <asp:TextBox ID="txtIfChecked" runat="server" Style="display: none"></asp:TextBox>
    <asp:TextBox ID="txtJTGUID" runat="server" Style="display: none"></asp:TextBox>
    <table style="font-size: 9pt" height="48px" cellspacing="0" cellpadding="0" width="100%">
        <tr>
            <td height="1">
                <mnu:AppFormMenu ID="appFormMenu" runat="server" />
            </td>
        </tr>
        
    </table>
    <div style="padding-right: 15px; padding-left: 15px; padding-bottom: 15px; padding-top: 15px">
    <table  style="font-size: 9pt"  cellspacing="0" cellpadding="0" >
     <tr>
       <td>
       文件夹名称：  <asp:TextBox ID="DocumentDir" runat="server" ReadOnly="true" Width="89%" ></asp:TextBox>
       <asp:TextBox ID="DocumentGUID" runat="server" style="display:none" Width="89%" ></asp:TextBox>
       </td>
       </tr>
       <tr >
       <td>
        <div style="float:left"><input id="isTBcheck" type="checkbox" onclick="onIsCheck()"  />  将权限同步到子目录 &nbsp;&nbsp;&nbsp; </div><div id="isTB" style="float:left;width:60%; ">&nbsp;&nbsp;  同步方式：<input type="radio" name="docscope" checked  id="rdoAll"/>覆盖 <input type="radio" name="docscope" id="rdoAdd"/>追加</div> 
       </td>
     </tr>
      
       <tr height="1">
            <td>
                <mnu:AppGridMenu ID="appGridMenu" runat="server" />
            </td>
        </tr>
        <tr>
            <td valign="top" style="height:420px;">
                <!-- repeater -->
            <mwc:repeater id="Repeater1" runat="server" SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">' SortSignASC='<img src="/_imgs/ico_arrow_u.gif">' EnablePager="False">
			<FooterTemplate>
			</table>
			</div> </td> </tr> 
			<!-- 列表行 -->
			</table> </FooterTemplate>
			<ItemTemplate>
				<tr style="CURSOR: hand" height="24" StationUserGuid='<%# DataBinder.Eval(Container.DataItem, "StationUserGuid") %>'>
					<td class="gridBorder" align="center" colspan="2"><input type="checkbox" id='chk_User'></td>
					<td class="gridBorder" align="left" colspan="2" noWrap><%# DataBinder.Eval(Container.DataItem, "Type") %></td>
					<td class="gridBorder" align="left" colspan="2"><%# DataBinder.Eval(Container.DataItem, "StationUserName") %></td>
				</tr>
			</ItemTemplate>
			<HeaderTemplate>
				<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" style="BACKGROUND-COLOR: white;table-layout:fixed">
					<TBODY>
						<!-- 列表行 -->
						<tr valign="top">
							<td>
								<div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 100%;">
									<table id="gridBar" cellpadding="0" cellspacing="0" border="0" MultiSelect="true" gridID="Repeater1"
										style="table-layout:fixed">
										<colgroup id="gridBarCols">
											<col width="40">
											<col width="2">
											<col width="80">
											<col width="2">
											<col>
											<col width="2">
										</colgroup>
										<TBODY>
											<tr id="trHeader" pagesize="" align="center" height="23" style="CURSOR:hand">
												<td align="center" class="gridBar"><input type="checkbox" id="chkAll" title="选择本页所有记录" onclick="doCheckAll(this)"></td>
												<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
												<td class="gridBar"><nobr>类别</nobr></td>
												<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
												<td class="gridBar"><nobr>岗位成员名称</nobr></td>
												<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
											</tr>
			</HeaderTemplate>
			</mwc:repeater> 
            </td>
        </tr>
       <%-- <tr height="40">
            <td class="buttons">
                <button onclick="Ok()" id="btnOk" type="button">
                    确 定</button>&nbsp;&nbsp;
                <button onclick="parent.window.close();" type="button">
                    取 消</button>
            </td>
        </tr>--%>
    </table>
    </div>
    </form>
</body>
</html>
